//
//  HAUpdatePopView.m
//  HA
//
//  Created by sy on 2023/12/17.
//

#import "HAUpdatePopView.h"

@implementation HAUpdatePopView

-(instancetype)init {
    if (self = [super init]) {

        [self layoutViews];
    }
    return self;

}


-(void)buttomleftButtonClick {
    NSString *url = self.ios_url;
    if ([NSString isEmptyString:url]) {
        url = @"https://apps.apple.com/us/app/卡合宝/id6474763238";
    }
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:nil];
    }
}

-(void)layoutViews {
    
    self.frame = CGRectMake(0, 0, kUIScreen_w, kUIScreen_h);
    [self addSubview:self.backgroundView];
    
    CGFloat alertViewW = 248;
    CGFloat alertViewH = 148;
    CGFloat alertViewX = (kUIScreen_w-alertViewW)*0.5;
    CGFloat alertViewY = (kUIScreen_h-alertViewH)*0.5;
    self.alertViewY = alertViewY;
    self.alertView.frame = CGRectMake(alertViewX, alertViewY, alertViewW, alertViewH);
    [self addSubview: self.alertView];
    self.alertView.layer.cornerRadius = 5;
    self.alertView.layer.masksToBounds = YES;
    
    UILabel *conLabel = [UILabel ha_NLabelWithFont:18 textColor:@"#333333" text:@"发现新版本" alignment:1];
    [self.alertView addSubview:conLabel];
    [conLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(44);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
    }];
    
    UIButton *leftButton = [[UIButton alloc]init];
    leftButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [leftButton setTitle:@"去更新" forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(buttomleftButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [leftButton setTitleColor:[UIColor colorWithHexString:@"#303133"] forState:0];
    [self.alertView addSubview:leftButton];
    [leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-10);
        make.width.mas_offset(100);
        make.height.mas_offset(40);
    }];

}



@end
